﻿using System;

namespace CodeLabs.Util
{
    public static class PatternValidator
    {
        /// <summary>
        /// check whether the provided string is a valid url
        /// </summary>
        public static bool IsValidHttpUrl(this string url)
        {
            Uri validatedUri;

            if (Uri.TryCreate(url, UriKind.Absolute, out validatedUri)) //.NET URI validation.
            {                
                return (validatedUri.Scheme == Uri.UriSchemeHttp || validatedUri.Scheme == Uri.UriSchemeHttps);
            }
            return false;
        }

    }
}
